package game.core
{
	import engine.asset.*;
	import engine.graphics.vfx.*;
	import engine.loaders.*;
	import engine.sound.*;
	import game.actor.*;
	import game.localization.*;
	import game.messages.gamedata.*;
	import game.scene.*;
	import game.ui.core.*;
	
	public class RxSequence
	{
		private var m_actor:RxActor;
		private var m_target:RxActor;
		private var m_ability:String;
		private var m_abilityIndex:int;
		private var m_sequence:String;
		private var m_index:int;
		private var m_time:Number;
		private var m_endTime:Number;
		private var m_loop:int;
		private var m_checkForChain:Boolean;
		private var m_speedPushed:int;
		private var m_anim:RxAnim;
		private var m_spawnedVFX:Array;
		private var m_spawnedHitFX:Array;
		private var m_trackedObject:RxLoader3D;
		private var m_timeScale:Number;
		private var m_events:Array;
		private var m_eventTimes:Array;
		private var m_blocked:String;
		private var m_funcs:Object;
		private var m_instantFuncs:Object;
		private static var s_sequence:Object = {};
		private static var s_exitSequence:Object = {};
		private static var s_looping:Object = {};
		
		public function RxSequence(actor:RxActor)
		{
			this.m_funcs = {};
			this.m_instantFuncs = {};
			this.m_actor = actor;
			this.m_target = null;
			this.m_ability = null;
			this.m_abilityIndex = 0;
			this.m_anim = null;
			this.m_trackedObject = null;
			this.m_sequence = null;
			this.m_index = 0;
			this.m_time = 0;
			this.m_endTime = 0;
			this.m_loop = 0;
			this.m_checkForChain = false;
			this.m_speedPushed = 0;
			this.m_spawnedVFX = new Array();
			this.m_spawnedHitFX = new Array();
			this.m_timeScale = 1;
			this.m_events = new Array();
			this.m_eventTimes = new Array();
			this.m_blocked = null;
			this.AddFunc("anim", this.funcAnim, false);
			this.AddFunc("sound", this.funcSound, true);
			this.AddFunc("othersound", this.funcSound, true);
			this.AddFunc("vfx", this.funcVFX, false);
			this.AddFunc("killvfx", this.funcKillVFX, false);
			this.AddFunc("shake", this.funcShake, false);
			this.AddFunc("hitfx", this.funcHitFX, false);
			this.AddFunc("killhitfx", this.funcKillHitFX, false);
			this.AddFunc("hit", this.funcHit, true);
			this.AddFunc("prehit", this.funcPreHit, true);
			this.AddFunc("projectile", this.funcProjectile, true);
			this.AddFunc("chain", this.funcChain, true);
			this.AddFunc("speed", this.funcSpeed, false);
			this.AddFunc("setlength", this.funcLength, false);
			this.AddFunc("hideItem", this.funcHideItem, false);
			this.AddFunc("showItem", this.funcShowItem, false);
			this.AddFunc("delete", this.funcDelete, true);
			this.AddFunc("colorflash", this.funcColorFlash, false);
			this.AddFunc("targetcolorflash", this.funcColorFlash, false);
			this.AddFunc("playontarget", this.funcPlayOnTarget, true);
			this.AddFunc("ownerevent", this.funcOwnerEvent, true);
			this.AddFunc("block", this.funcBlock, false);
			this.AddFunc("say", this.funcSay, false);
			this.AddFunc("interact", this.funcInteract, false);
		}
		
		private function AddFunc(key:String, fun:Function, bol:Boolean) : void
		{
			this.m_funcs[key] = fun;
			if (bol == true)
			{
				this.m_instantFuncs[key] = fun;
			}
		}

		public function SetAnimModel(model:RxLoader3D, animSuite:String, stance:String) : void
		{
			if (model != null)
			{
				//this.m_anim = new RxAnim(model, animSuite, stance);
			}
			else
			{
				this.m_anim = null;
			}
		}
		
		public function SetTrackedObject(trackedObject:RxLoader3D) : void
		{
			this.m_trackedObject = trackedObject;
		}
		
		public function IsRunning() : int
		{
			if (this.m_sequence == null)
			{
				return 0;
			}
			return 1;
		}
		
		public function get currentSequence() : String
		{
			return this.m_sequence;
		}
		
		public function get CurrentTime() : Number
		{
			return this.m_time;
		}
		
		public function get CurrentLength() : Number
		{
			return this.m_endTime;
		}
		
		public function get CheckForChain() : Boolean
		{
			return this.m_checkForChain;
		}
		
		public function set CheckForChain(xml:Boolean) : void
		{
			this.m_checkForChain = xml;
			return;
		}
		
		public function get anim() : String
		{
			if (this.m_anim == null)
			{
				return null;
			}
			return this.m_anim.anim;
		}
		
		public function SetTimeScale(timeScale:Number) : void
		{
			this.m_timeScale = timeScale;
		}
		
		public function GetTimeScale() : Number
		{
			return this.m_timeScale;
		}
		
		public function PushEvent(event:String, time:Number) : void
		{
			this.m_events.push(event);
			this.m_eventTimes.push(time);
		}
		
		private function funcAnim(xml:XML) : void
		{

		}
		
		private function funcSound(xml:XML) : void
		{

		}
		
		private function funcVFX(xml:XML) : void
		{

		}
		
		private function funcKillVFX(xml:XML) : void
		{

		}
		
		private function funcShake(xml:XML) : void
		{

		}
		
		private function funcHitFX(xml:XML) : void
		{
		
		}
		
		private function funcKillHitFX(xml:XML) : void
		{
			
		}
		
		private function funcPreHit(xml:XML) : void
		{

		}
		
		private function funcHit(xml:XML) : void
		{

		}
		
		private function funcProjectile(xml:XML) : void
		{

		}
		
		private function funcChain(xml:XML) : void
		{
			this.m_checkForChain = true;
		}
		
		private function funcSpeed(xml:XML) : void
		{

		}
		
		private function funcLength(xml:XML) : void
		{
			this.m_endTime = this.m_time + xml.@setlength;
		}
		
		private function funcHideItem(xml:XML) : void
		{

		}
		
		private function funcShowItem(xml:XML) : void
		{

		}
		
		private function funcDelete(xml:XML) : void
		{

		}
		
		private function funcColorFlash(xml:XML) : void
		{

		}
		
		private function funcPlayOnTarget(xml:XML) : void
		{

		}
		
		private function funcOwnerEvent(xml:XML) : void
		{

		}
		
		private function funcBlock(xml:XML) : void
		{
			this.m_blocked = xml.@event;
		}
		
		private function funcSay(xml:XML) : void
		{

		}
		
		private function funcInteract(xml:XML) : void
		{

		}
		
		public static function Parse(param1:String) : void
		{
			var _loc_4:XML = null;
			var _loc_5:int = 0;
			var _loc_6:String = null;
			var _loc_7:Array = null;
			var _loc_8:XML = null;
			var _loc_9:Array = null;
			var _loc_10:XML = null;
			var _loc_2:* = RxAssetXML.GetByURL(param1);
			var _loc_3:* = _loc_2.GetXML();
			for each (_loc_4 in _loc_3.sequence)
			{
				
				_loc_5 = 0;
				if (_loc_4.hasOwnProperty("@looping") == true)
				{
					_loc_5 = _loc_4.@looping;
				}
				_loc_6 = _loc_4.@name;
				_loc_7 = new Array();
				for each (_loc_8 in _loc_4.event)
				{
					
					_loc_7.push(_loc_8);
				}
				s_sequence[_loc_6] = _loc_7;
				s_looping[_loc_6] = _loc_5;
				_loc_9 = new Array();
				for each (_loc_10 in _loc_4.exit)
				{
					
					_loc_9.push(_loc_10);
				}
				if (_loc_9.length > 0)
				{
					s_exitSequence[_loc_6] = _loc_9;
				}
			}
		}
	}
}